public class simulate {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int sum = 0;
        int len = timeSeries.length;
        for (int i = 0; i < len; i++) {
            sum += duration;
            if (i + 1 < len && timeSeries[i + 1] <= timeSeries[i] + duration - 1) {//去掉两个时间段重复的部分
                sum -= (timeSeries[i] + duration - 1 - timeSeries[i + 1] + 1);
            }
        }
        return sum;
    }
}
